import React, { Component, Fragment } from 'react';
import { connect } from 'dva'
import Link from 'umi/link';
import { Icon } from 'antd';
import GlobalFooter from '@/components/GlobalFooter';
import DocumentTitle from 'react-document-title';
import styles from './UserLayout.less';
import logo from '../assets/logo2.png';
import getPageTitle from '@/utils/getPageTitle';

@connect(({ global }) => ({
  global,
}))

class UserLayout extends Component {
  state = {
    verionData: {},
  }
  componentDidMount() {
    const {
      dispatch,
      route: { routes, authority },
    } = this.props;

    dispatch({
      type: 'menu/getMenuData',
      payload: { routes, authority },
    });

    this.infoList();

  }

  infoList() {
    const { dispatch } = this.props;
    dispatch({
      type: 'global/infoList',
      callback: (res) => {
        this.setState({
          verionData: res.data,
        })
      },
    })
  }

  render() {
    const {verionData}=this.state;
    const {
      children,
      location: { pathname },
      breadcrumbNameMap,
    } = this.props;
    return (
      <DocumentTitle title={getPageTitle(pathname, breadcrumbNameMap)}>
        <div className={styles.container}>
          <div className={styles.logo}>
            <img alt="logo" src={logo} style={{width: 150}} />
          </div>
          <div className={styles.content}>
            <div className={styles.desc}>
              <div className={styles.top}>
                <span className={styles.title}>{verionData&&verionData.systemTitle}</span><br/>
                <span className={styles.littleT}>{verionData&&verionData.systemSubtitle}</span>
              </div>
              {children}
            </div>
          </div>
          <div className={styles.footer}>
            <span>
              Copyright <Icon type="copyright" /> {verionData&&verionData.copyRightInfo}
            </span>
          </div>
        </div>

      </DocumentTitle>
    );
  }
}

export default connect(({  menu: menuModel, global}) => ({
  menuData: menuModel.menuData,
  breadcrumbNameMap: menuModel.breadcrumbNameMap,
}))(UserLayout);





